﻿using FluentValidation;
using Jupiter.Infrastructure.Domain;
using MediatR;

namespace Wips.AppService.Publisher.PublishFlows.Requests
{

    /// <summary>
    /// 开始流程
    /// </summary>
    public class StartPublishRequest : IRequest<string>,ITxRequest
    {

        /// <summary>
        /// 归属服务
        /// </summary>
        public string AgentServerConfigId { get; set; } = "";


        /// <summary>
        /// 归属服务器
        /// </summary>
        public string AgentServerId { get; set; } = "";


        /// <summary>
        /// 发布流程名称
        /// </summary>
        public string Name { get; set; } = "";

        /// <summary>
        /// 发布内容
        /// </summary>
        public string Context { get; set; } = "";

    }


    /// <summary>
    /// 校验
    /// </summary>
    public class StartPublishRequestValidator : AbstractValidator<StartPublishRequest>
    {
        /// <summary>
        /// 
        /// </summary>
        public StartPublishRequestValidator()
        {
            RuleFor(p => p.Name)
                .Must(p => !string.IsNullOrEmpty(p))
                .WithMessage("Name不能为空");


            RuleFor(p => p.AgentServerConfigId)
               .Must(p => !string.IsNullOrEmpty(p))
               .WithMessage("AgentServerConfigId不能为空");

            RuleFor(p => p.AgentServerId)
               .Must(p => !string.IsNullOrEmpty(p))
               .WithMessage("AgentServerId不能为空");

        }
    }
}


